package sz.szsmk.citizencard.util.zxyh;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;


import java.io.ByteArrayOutputStream;


/**
 * Created by wutw on 2018/5/23 0023.
 */
public class OcrlibInterfaceImpl  {

    public static Context sContext;

    private String  appkey;
    private static final String DIR_IMG_RESULT = Environment.getExternalStorageDirectory()+"/idcardscan/";
    public static final String BANKCARD_TRIM_DIR = Environment.getExternalStorageDirectory()+"/trimedcard.jpg";
    public static final String BANKCARD_ORG_DIR = Environment.getExternalStorageDirectory()+"/origiancard.jpg";

    private OcrlibInterfaceImpl() {
    }


    public static byte[] loadBitmap(String pathName) {
        Bitmap b = null;
        byte[] byteArray=null;
        try {
            BitmapFactory.Options opts = new BitmapFactory.Options();
            opts.inPreferredConfig = Bitmap.Config.ARGB_8888;
            b = BitmapFactory.decodeFile(pathName, opts);


            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            b.compress(Bitmap.CompressFormat.JPEG, 100, baos);

            byteArray=baos.toByteArray();
        } catch (Exception e) {
            e.printStackTrace();
            b = null;
        } catch (OutOfMemoryError e) {
            e.printStackTrace();
            b = null;
        }finally {
            if(b!=null) b.recycle();
        }
        return byteArray;
    }


}
